﻿namespace Tester.Models;

internal class Message
{
    private static Dictionary<string, Action<string, string, string>> actions = new Dictionary<string, Action<string, string, string>>();
    private static Dictionary<string, Action<string, string, string, string>> actions3 = new Dictionary<string, Action<string, string, string, string>>();
    private static Dictionary<string, Action> actions2 = new Dictionary<string, Action>();

    public static void Register(Action<string, string, string> action, string key)
    {
        if (!actions.ContainsKey(key))
        {
            actions.Add(key, action);
        }
    }
    public static void Register(Action action, string key)
    {
        if (!actions2.ContainsKey(key))
        {
            actions2.Add(key, action);
        }
    }
    public static void Register(Action<string, string, string, string> action, string key)
    {
        if (!actions3.ContainsKey(key))
        {
            actions3.Add(key, action);
        }
    }

    public static void Show(string key, string title, string details, string button)
    {
        if (actions.ContainsKey(key))
        {
            actions[key]?.Invoke(title, details, button);
        }
    }

    public static void Show(string key, string title, string details, string accept, string cancel)
    {
        if (actions3.ContainsKey(key))
        {
            actions3[key]?.Invoke(title, details, accept, cancel);
        }
    }
    public static void Execute(string key)
    {
        if (actions2.ContainsKey(key))
        {
            actions2[key]?.Invoke();
        }
    }
}